package com.study.modules.mini.wxjava;

import com.study.config.MiniConfig;
import com.study.modules.mini.wxjava.WxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author gexiaotong
 * @ClassName WxMultiService
 * @Date 2022-11-30  18:56
 * @Version 1.0
 */
@Slf4j
@Service
public class WxMultiService {


    @Autowired
    private MiniConfig miniConfig;

    private Map<String, WxService> map = new ConcurrentHashMap<>();

    /**
     * 获取wxService
     *
     * @return
     */
    public WxService getWxService(String appid) {
        if (map.containsKey(appid)) {
            return map.get(appid);
        }
        WxService wxService = new WxService(appid, miniConfig);
        map.put(appid, wxService);
        return wxService;

    }
}
